package com.shd.edanpei.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseQuickImageAdapter;
import com.shd.edanpei.common.Constant;
import com.shd.edanpei.bean.UpFileBean;
import com.socks.library.KLog;

/**
 * Created by mc on 2018/9/23.
 * yang-wen-wen
 */

public class UpFileAdapter extends BaseQuickImageAdapter<UpFileBean> {

    private int type;

    public UpFileAdapter(Context context, int type) {
        super(context, R.layout.item_upfile);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, UpFileBean item) {
//        helper.getView(R.id.tv_add).setAlpha((float) 0.22);
        if (type == Constant.SHOW) {
            helper.getView(R.id.tv_add).setVisibility(View.GONE);
            helper.getView(R.id.iv_add).setVisibility(View.GONE);
        } else {
            helper.getView(R.id.tv_add).setVisibility(item.isMust() ? View.GONE : View.VISIBLE);
            helper.getView(R.id.iv_add).setVisibility(item.isMust() ? View.GONE : View.VISIBLE);
        }
        helper.getView(R.id.tv_hint).setVisibility(TextUtils.isEmpty(item.getDownStr()) ? View.INVISIBLE : View.VISIBLE);
        helper.setText(R.id.tv_hint, item.getDownStr());

        if (!TextUtils.isEmpty(item.getUrl())) {
            helper.getView(R.id.tv_add).setVisibility(View.GONE);
            mLoadImgCtrl.getGlide().load(item.getUrl()).into((ImageView) helper.getView(R.id.iv_pic));
            KLog.e("pic"+helper.getLayoutPosition());
        }


    }

}
